#ifndef SNAKE_H
#define SNAKE_H

#include <QMainWindow>
#include <QQueue>
#include <QVector>
#include <QPalette>

namespace Ui {
class Snake;
}

class Snake : public QMainWindow
{
    Q_OBJECT

public:
    explicit Snake(QWidget *parent = 0);
    ~Snake();
    void paintEvent(QPaintEvent *event);
    void InitSnake();
    void keyPressEvent(QKeyEvent *event);

    void createRect();
    void rectsDown();
    QRect Createect();


    bool isCrash();

private slots:
     void Snake_update();

private:
    Ui::Snake *ui;

    QQueue<QVector<QRect>> qRects;

    QTimer *timer;//定时器
    int frameSpeed = 150;//帧速，200ms一帧
    int density = 1;
    int nPosition=-1;//按键位置
    bool isRun;
    int nScore;//得分
    int nScorex;//判定的得分
    QString scoreLabel;//显示得分两个字
     QRect food;//食物
     int shi = 0;//时间判定
     int life = 3;//生命值
    QString lifeLabel;

    int personX = 250;//玩家初始坐标
    int personY = 600;
};

#endif // SNAKE_H
